﻿app.controller('AddNewChurchWorkerController', ['$scope', 'GlobalService', 'fileUpload', 'ApplicationService', 'alertboxservice', function ($scope, GlobalService, fileUpload, ApplicationService, alertboxservice) {

    $scope.Genders = GlobalService.GetGender();

    function BindChurchWorkerDesignation() {
        var url = "../../Admin/ChurchWorkerMaster/GetAllChurchWorkerDesignation";
        ApplicationService.Getdata(url).success(function (data) {
            $scope.GetChurchWorkerDesignation = data;
        });
    }

    BindChurchWorkerDesignation();

    $scope.save = function (modelstate, id) {

        $scope.buttonstate = true;
        var url;
        switch (modelstate) {
            case 'add':
                url = "AddChurchBoardJobtitle";
                break;
            case 'edit':
                url = "UpdateChurchBoardJobtitle";
                break;
        }

        ApplicationService.Save($scope.BoardJobtitle, url).success(function (result) {
            alertboxservice.ShowMsg(result, "Jobtitle ");
            $scope.buttonstate = false;
            BindGrid();
        });
    }

}]);

